// 笔试强训day30:爱吃素

#include <iostream>
#include <math.h>
using namespace std;

bool isPrime(long long n)
{
    if(n == 1) return false;
    for(long long i = 2; i <= sqrt(n); i++)
    {
        if(n % i == 0) return false;
    }
    return true;
}

int main() {
    int T = 0; cin >> T;
    while(T--)
    {
        long long a, b; cin >> a >> b;
        if((a == 1 || b == 1) && (isPrime(a) || isPrime(b)))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}